#pragma once 

#include "Socket.hpp"
#include "Reactor.hpp"
using namespace SocketModule;
class listner 
{
public:
    listner(uint16_t port)
        :_port(port)
        {
            _listen_socket = std::make_shared<Tcpsocket>();
        }
    void Init()
    {
        _listen_socket->BuildTcpserver(_port);
    }
    void Acceptor(Reactor*owner) 
    {
        InetAddr peer; 
        int socketfd = _listen_socket->accpetor(&peer);
        if (socketfd < 0) 
        {
            LOG(LogLevel::WARNING) << "accept error";
            Die(ACCEPT_ERROR);
        }
        //构建connection，连入到epoll中
        auto conn = std::make_shared<Connection>(socketfd);
        
    }
    int Fd() { 
        return _listen_socket->FD();
    }
    ~listner(){}
private:
    uint16_t _port;
    std::shared_ptr<Socket> _listen_socket;
};  